package io.renren.modules.sys.entity;

import io.renren.modules.generator.entity.CompanyEntity;
import io.renren.modules.generator.entity.IndustryEntity;
import lombok.Data;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 部门实体
 */
@Data
public class DeptEntity {
    /**
     * 部门id
     */
    private Integer deptId;
    /**
     * 部门名称
     */
    private String deptName;

    public static List<DeptEntity> convertCompaniesToDeptList(List<CompanyEntity> companyEntities) {
        if (CollectionUtils.isEmpty(companyEntities)) {
            return null;
        }
        List<DeptEntity> deptEntityList = new ArrayList<>();
        for (CompanyEntity company : companyEntities) {
            DeptEntity deptEntity = new DeptEntity();
            deptEntity.setDeptId(company.getId());
            deptEntity.setDeptName(company.getCompanyName());
            deptEntityList.add(deptEntity);
        }

        return deptEntityList;
    }

    public static List<DeptEntity> convertIndustriesToDeptList(List<IndustryEntity> industryEntities) {
        if (CollectionUtils.isEmpty(industryEntities)) {
            return null;
        }
        List<DeptEntity> deptEntityList = new ArrayList<>();
        for (IndustryEntity industryEntity : industryEntities) {
            DeptEntity deptEntity = new DeptEntity();
            deptEntity.setDeptId(industryEntity.getId());
            deptEntity.setDeptName(industryEntity.getIndustryName());
            deptEntityList.add(deptEntity);
        }

        return deptEntityList;
    }
}
